package com.turnengine.client.local.error.bean;

import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import java.io.IOException;

/**
 * The Local Trace Serializer.
 */
public class LocalTraceSerializer implements ILocalTraceSerializer {

	@Override
	public ILocalTrace readObject(IDataReader reader) throws IOException {

		// Read fields
		String id = reader.readString(true);
		long datetime = reader.readLong();
		String trace = reader.readString(true);

		// Create object
		ILocalTrace object = new LocalTrace();
		object.setId(id);
		object.setDatetime(datetime);
		object.setTrace(trace);
		return object;
	}

	public void writeObject(IDataWriter writer, ILocalTrace object) throws IOException {

		// Get fields
		String id = object.getId();
		long datetime = object.getDatetime();
		String trace = object.getTrace();

		// Write fields
		writer.writeString(id, true);
		writer.writeLong(datetime);
		writer.writeString(trace, true);
	}
}
